﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CoreBDS;

namespace BatDongSan.Modules
{
    public partial class Uct_FieldOfBusiness_Menu : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadMenu();
        }
        public void LoadMenu()
        {
            try
            {
                ltrTitle.Text = "LĨNH VỰC HOẠT ĐỘNG";
                List<Cvk_FieldOfBusiness> listChild = FieldOfBusinessBll.GetList(Utility.strConnect);
                if (listChild.Count > 0)
                {

                    rptField.DataSource = listChild;
                    rptField.DataBind();
                    //System.Text.StringBuilder query = new System.Text.StringBuilder();
                    //for (int j = 0; j < listChild.Count; j++)
                    //{
                    //    if (j == 0)
                    //        query.AppendLine("<li class=\"top\">");
                    //    else if (j == listChild.Count - 1)
                    //        query.AppendLine("<li class=\"bot\">");
                    //    else
                    //        query.AppendLine("<li class=\"middle\">");

                    //    query.AppendLine(string.Format("<a href=\"http://{0}/ChildCategories.aspx?catid={1}\">{2}</a>", Request.Url.Authority, listChild[j].CategoryId, listChild[j].Name));
                    //    query.AppendLine("</li>");
                    //}
                    //ltrMenu.Text = query.ToString();
                }
            }
            catch { }
        }
        protected void rptField_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            try
            {
                if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
                {
                    Cvk_FieldOfBusiness info = (Cvk_FieldOfBusiness)e.Item.DataItem;
                    HyperLink hplSubject = (HyperLink)e.Item.FindControl("hplSubject");
                    hplSubject.Text = info.Name;
                    hplSubject.ToolTip = info.Name;
                    hplSubject.NavigateUrl = string.Format("/Businesses.aspx?idf={0}", info.FieldId);
                    //hplSubject.NavigateUrl = string.Format("http://{0}/{1}/{2}/{3}.htm", Request.Url.Authority, NewsBll.claNewsTypeDetail.GetUrlFriendly(1, info.NewsTypeId, Utility.strConnect), info.NewsId, info.SeoUrl);
                }
            }
            catch { }
        }
    }
}